/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.wfaces.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

/**
 *
 * @author lhoussin
 */
@Entity
@Table(name = "groupe_user")
@NamedQueries({
    @NamedQuery(name = "GroupeUser.findAll", query = "SELECT g FROM GroupeUser g")})
public class GroupeUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dt_jointure")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dtJointure;
    @Basic(optional = false)
    @NotNull
    @Column(name = "add_by")
    private long addBy;
    @JoinColumn(name = "groupe", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Groupe groupe;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "user", fetch = FetchType.LAZY)
    private List<GroupeUser> groupeUserList;
    @JoinColumn(name = "user", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private GroupeUser user;

    public GroupeUser() {
    }

    public GroupeUser(Long id) {
        this.id = id;
    }

    public GroupeUser(Long id, Date dtJointure, long addBy) {
        this.id = id;
        this.dtJointure = dtJointure;
        this.addBy = addBy;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getDtJointure() {
        return dtJointure;
    }

    public void setDtJointure(Date dtJointure) {
        this.dtJointure = dtJointure;
    }

    public long getAddBy() {
        return addBy;
    }

    public void setAddBy(long addBy) {
        this.addBy = addBy;
    }

    public Groupe getGroupe() {
        return groupe;
    }

    public void setGroupe(Groupe groupe) {
        this.groupe = groupe;
    }

    public List<GroupeUser> getGroupeUserList() {
        return groupeUserList;
    }

    public void setGroupeUserList(List<GroupeUser> groupeUserList) {
        this.groupeUserList = groupeUserList;
    }

    public GroupeUser getUser() {
        return user;
    }

    public void setUser(GroupeUser user) {
        this.user = user;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GroupeUser)) {
            return false;
        }
        GroupeUser other = (GroupeUser) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.wfaces.entities.GroupeUser[ id=" + id + " ]";
    }
    
}
